﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HttpServer.Restful
{
    [Serializable]
    public class JsonResult
    {
        private int code;
        private string message;
        private Object data;

        public int Code { get => code; set => code = value; }
        public string Message { get => message; set => message = value; }
        public Object Data { get => data; set => data = value; }



        public static JsonResult ok()
        {
            return ok(null, null);
        }

        public static JsonResult ok(string message)
        {
            return ok(message, null);
        }

        public static JsonResult ok(object data)
        {
            return ok(null, data);
        }

        public static JsonResult ok(string message, Object data)
        {
            JsonResult jsonResult = new JsonResult();
            jsonResult.Code = 200;
            jsonResult.Message = message;
            jsonResult.Data = data;
            return jsonResult;
        }







        public static JsonResult fail(string messge)
        {
            return fail(messge, null);
        }

        public static JsonResult fail(string messge, object data)
        {
            JsonResult jsonResult = new JsonResult();
            jsonResult.Code = 500;
            jsonResult.Message = messge;
            jsonResult.Data = data;
            return jsonResult;
        }

    }
}
